package com.example.child_protection.controller;

import com.example.child_protection.dto.base.BaseResponseDTO;
import com.example.child_protection.dto.request.SimpleIdRequestDTO;
import com.example.child_protection.dto.request.add.SystemShortcomingInsertRequestDTO;
import com.example.child_protection.dto.request.find.SystemShortcomingRequestDTO;
import com.example.child_protection.dto.request.update.SystemShortcomingContentUpdateRequestDTO;
import com.example.child_protection.dto.request.update.SystemShortcomingUpdateRequestDTO;
import com.example.child_protection.dto.response.SystemShortcomingListResponseDTO;
import com.example.child_protection.dto.response.SystemShortcomingResponseDTO;
import com.example.child_protection.service.SystemShortcomingManageService;
import com.example.child_protection.service.SystemShortcomingQueryService;
import com.example.child_protection.util.ContentType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 缺点管理控制层
 * @date 2018-11-2
 * @author Biz
 */
@RestController
@RequestMapping("systemShortcoming")
@Api(value = "/api-systemShortcoming", description = "缺点管理")
public class SystemShortcomingController extends BaseController {

    @Autowired
    public SystemShortcomingManageService systemShortcomingManageService;

    @Autowired
    public SystemShortcomingQueryService systemShortcomingQueryService;

    @ApiOperation(value ="查询缺点", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/findId", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public SystemShortcomingResponseDTO findId(SimpleIdRequestDTO requestDTO,HttpServletRequest request)throws Exception{
        SystemShortcomingResponseDTO responseDTO = systemShortcomingQueryService.findId(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="查询缺点列表信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/findList", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public SystemShortcomingListResponseDTO findList(SystemShortcomingRequestDTO requestDTO, HttpServletRequest request)throws Exception{
        SystemShortcomingListResponseDTO responseDTO = systemShortcomingQueryService.findList(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="添加缺点", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/insert", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO insert(SystemShortcomingInsertRequestDTO requestDTO)throws Exception{
        requestDTO.setCreatePersonId(this.getLoginUserId());
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemShortcomingManageService.insert(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="修改缺点", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO update(SystemShortcomingUpdateRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemShortcomingManageService.update(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="修改缺点文本编辑器内容", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/updateContent", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO updateContent(SystemShortcomingContentUpdateRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemShortcomingManageService.updateContent(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="删除缺点", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO delete(SimpleIdRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemShortcomingManageService.delete(requestDTO);
        return responseDTO;
    }

}
